package com.pro.springbootshop.service.impl;

import com.pro.springbootshop.entity.Seller;
import com.pro.springbootshop.mapper.SellerMapper;
import com.pro.springbootshop.service.SellerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SellerServiceImpl implements SellerService {
    public SellerMapper sellerMapper;
    @Autowired
    public void setUserMapper (SellerMapper sellerMapper) {
        this.sellerMapper = sellerMapper;
    }
    @Override
    public String loginSeller(Seller seller) {
        Seller newSeller=sellerMapper.sellerLogin(seller.getSellerId(),seller.getSellerPw());
        if(newSeller==null){
            return null;
        }else{
            return "seller-token";
        }
    }

    @Override
    public Seller getSeller(String token) {
        if(token.equals("seller-token")){
            Seller seller=sellerMapper.selectById(1);
            seller.setSellerPw("");
            return seller;
        }else{
            return null;
        }
    }
}
